import Vue from 'vue'
import Router from 'vue-router'
import { Message  } from 'element-ui'

// 登陆
import Login from '@/views/login'

import Index from '@/views/index'
// 首页
import Home from '@/views/home'

import UserManageIndex from '@/views/user-management-index'
// 用户管理
import UserManage from '@/views/user-management'
// 用户权限管理

import UserRestricManage from '@/views/user-restric-management'
// 人机训练
import HumanMachineTraining from '@/views/human-machine-training'

// 我的课程
import MyCourses from '@/views/my-courses'
// MarkSimos 
import MarkSimos from '@/views/markSimos'
// ChangeMan
import ChangeMan from '@/views/changeMan'
//  我的比赛
import MyGame from '@/views/myGame'
// 攻略百科
import RaidersEncyclopedia from '@/views/raiders-encyclopedia'
// 高手回顾
import MasterReview from '@/views/master-review'
// 历史成绩
import HistoryResult from '@/views/history-result'
// 测试
import Test from '@/views/test'
// 线上指导
import OnlineInstruction from '@/views/online-instruction'
// 学员修改资料
import StudentInformation from '@/views/student-information'
// 测试管理
import TestManagement from '@/views/test-management'
// 学员管理
import StudentManagement from '@/views/student-management'
// 公告管理
import AnnouncementManagement from '@/views/announcement-management'
// 客服管理
import CustomerService from '@/views/customer-service'
// 下属管理
import SubordinateManagement from '@/views/subordinate-management'
// 管理员 课程详情
import CourseDetails from '@/views/course-details'
// 管理员 首页
import AdminHome from '@/views/adminHome'
// 创建课程
import CreateCourse from '@/views/create-course'
// 课程详情页
import CourseDetailsPage from '@/views/course-details-page'
// 管理员资料修改
import AdministratorModifiy from '@/views/administrator-modifiy'
// 课程详情页
import MarkSimosDetails from '@/views/markSimos-details'
// 攻略百科 理论列表页
import ToolList from '@/views/toolList'
// 攻略百科 理论列详情表页
import ToolListDetails from '@/views/toolList-details'
// 个人忘记密码
import ForgetPassword from '@/views/forgetPassword'
// 企业忘记密码
import BusinessForgetpassword from '@/views/businessForgetpassword'
// 企业密码修改
import BusinessResetPassword from '@/views/business-reset-password'
// GOD管理员登录
import GodLogin from '@/views/godLogin'
// GOD管理员登录--忘记密码
import GodForgetpassword from '@/views/godForgetpassword'
// GOD管理员登录--重置密码
import GodRestpassword from '@/views/godRestpassword'
// GOD管理员登录--修改邮箱
import ModifyEmail from '@/views/modify-email'
// GOD管理员登录--修改密码
import ModifyPassword from '@/views/modify-password'
// GOD管理员账号
import AdminCustomHome from '@/views/admin-custom-home'
// GOD管理员资料修改
import AdminCustomInformation from '@/views/admin-custom-information'
// GOD管理员账号设置
import AdminCustomSetup from '@/views/admin-custom-setup'
// GOD管理员--总管理员账号设置
import AdminCustomIndex from '@/views/admin-custom-index'
// GOD管理员--总管理员资料
import AdminCustomTotal from '@/views/admin-custom-total'
// GOD管理员--总管理员资料
import AdminCustomAll from '@/views/admin-custom-all'
// 行业通用词条
import IndustryRelated from '@/views/industry-related'
// 搜索词条
import SearchTerms from '@/views/search-terms'
// 可邀请创建课程
import InviteCreatCourses from '@/views/invite-creatCourses'
// 可邀请课程详情
import InviteCoursesDetails from '@/views/invite-coursesDetails'
// 创建课程--新版
import CreateGeneralCourse from '@/views/create-generalcourse'
// 管理员邀请课程
import AdminInviteCourse from '@/views/admin-inviteCourse'
// 可报名课程
import SignUpCourse from '@/views/sign-upCourse'
//我的成绩
import MyGrades from '@/views/myGrades'
// 短信H5
import ShortMessage from '@/views/shortMessage'
// 个人注册
import PersonalRegister from '@/views/personalRegister'
// 个人注册成功
import PersonalRegisterSuccess from '@/views/personal-register-success'
// 课程管理（管理员）
import CourseManagement from '@/views/course-management'
// 发起邀请
import InitiateInvitation from '@/views/initiate-invitation'
// 发起邀请详情页
import InitiateInvitationPage from '@/views/initiate-invitation-page'
// 课程列表（管理员）
import CurriculumSchedule from '@/views/curriculum-schedule'
// 创建一般课程详情
import GeneralCoursedetails from '@/views/general-coursedetails'
// 创建可邀请课程详情
import InviteCoursedetails from '@/views/invite-coursedetails'
// 反馈
import Feedback from '@/views/feedback'
// 报告
import Report from '@/views/report'
// 添加学员
import AddStudents from '@/views/addStudents'
// 个人课程列表
import PersonalCourseList from '@/views/personal-course-list'
// 新增学员
import NewAddStudent from '@/views/new-add-student'
// 邀请已有学员
import inviteHasStudent from '@/views/invite-has-student'
// 已接受邀请学员
import hasInviteParticipants from '@/views/has-invite-participants'






Vue.use(Router)

const router = new Router({
  	routes: [
    	{
      	path: '/',
      	name: 'Login',
      	component: Login
      },
      {
        path:'/forgetPassword',
        name:"forgetPassword",
        meta:{
          title:'个人忘记密码'
        },
        component:ForgetPassword
      },
      {
        path:'/businessForgetpassword',
        name:"businessForgetpassword",
        meta:{
          title:'企业忘记密码'
        },
        component:BusinessForgetpassword
      },
      {
        path:'/business-reset-password',
        name:"business-reset-password",
        meta:{
          title:'企业密码修改'
        },
        component:BusinessResetPassword
      },
      {
        path:'/personalRegister',
        name:"personalRegister",
        meta:{
          title:'个人注册'
        },
        component:PersonalRegister
      },
      {
        path:'/personal-register-success',
        name:"personal-register-success",
        meta:{
          title:'个人注册成功'
        },
        component:PersonalRegisterSuccess
      },
      {
        path:'/shortMessage',
        name:"shortMessage",
        meta:{
          title:'短信H5'
        },
        component:ShortMessage
      },
    	{
      	path: '/index',
      	name: 'Index',
      	component: Index,
        meta:{
          title:'ceshi'
        },
      	children:
      		[
	      		{
	      			path: '/home',
	      			name: 'home',
              meta:{
                  title: '首页',
              },
	      			component: Home
	      		},
            {
                path: '/user-management-index',
                name: 'user-management-index',
                meta:{
                    title: '用户管理',
                },
                component: UserManageIndex,
                children:[
                  {
                    path: '/user-management',
                    name: 'user-management',
                    meta:{
                        title: '用户信息管理',
                    },
                    component: UserManage
                  },
                  {
                    path: '/user-restric-management',
                    name: 'user-restric-management',
                    meta:{
                        title: '用户权限管理',
                    },
                    component: UserRestricManage
                  },
                ]
            },
            {
              path:'/human-machine-training',
              name:"human-machine-training",
              meta:{
                title:'人机训练'
              },
              component:HumanMachineTraining
            },
            {
              path:'/my-courses',
              name:'my-courses',
              meta:{
                  title:'我的课程'
              },
              component:MyCourses,
              children:[
                {
                  path:'/markSimos',
                  name:'markSimos',
                  meta:{
                    titl:'markSimos'
                  },
                  component:MarkSimos
                },
                {
                  path:'/changeMan',
                  name:'changeMan',
                  meta:{
                    titl:'changeMan'
                  },
                  component:ChangeMan
                },
              ]
            },
            {
              path:'/myGame',
              name:"myGame",
              meta:{
                title:'我的比赛'
              },
              component:MyGame
            },
            {
              path:'/raiders-encyclopedia',
              name:"raiders-encyclopedia",
              meta:{
                title:'攻略百科'
              },
              component:RaidersEncyclopedia,
              // children: [
              //   {
              //     path:'industry-related',
              //     name:"industry-related",
              //     meta:{
              //       title:'行业通用词条'
              //     },
              //     component:IndustryRelated
              //   },
              // ]
            },
            {
              path:'/industry-related/:id',
              name:"industry-related",
              meta:{
                title:'行业通用词条'
              },
              component:IndustryRelated
            },
            {
              path:'/search-terms',
              name:"search-terms",
              meta:{
                title:'搜索词条'
              },
              component:SearchTerms
            },

            {
              path:'/master-review',
              name:"master-review",
              meta:{
                title:'高手回顾'
              },
              component:MasterReview
            },
            {
              path:'/history-result',
              name:"history-result",
              meta:{
                title:'历史成绩'
              },
              component:HistoryResult
            },
            {
              path:'/test',
              name:"test",
              meta:{
                title:'测试'
              },
              component:Test
            },
            {
              path:'/online-instruction',
              name:"online-instruction",
              meta:{
                title:'线上指导'
              },
              component:OnlineInstruction
            },
            {
              path:'/student-information',
              name:"student-information",
              meta:{
                title:'学员修改资料'
              },
              component:StudentInformation
            },
            {
              path:'/test-management',
              name:"test-management",
              meta:{
                title:'测试管理'
              },
              component:TestManagement
            },
            {
              path:'/student-management',
              name:"student-management",
              meta:{
                title:'学员管理'
              },
              component:StudentManagement
            },
            
            {
              path:'/announcement-management',
              name:"announcement-management",
              meta:{
                title:'公告管理'
              },
              component:AnnouncementManagement
            },
            {
              path:'/customer-service',
              name:"customer-service",
              meta:{
                title:'客服管理'
              },
              component:CustomerService
            },
            {
              path:'/subordinate-management',
              name:"subordinate-management",
              meta:{
                title:'下属管理'
              },
              component:SubordinateManagement
            },
            {
              path:'/course-details',
              name:"course-details",
              meta:{
                title:'课程详情'
              },
              component:CourseDetails
            },
            {
              path:'/adminHome',
              name:"adminHome",
              meta:{
                title:'管理员-首页'
              },
              component:AdminHome
            },
            {
              path:'/create-course',
              name:"create-course",
              meta:{
                title:'创建课程'
              },
              component:CreateCourse
            },
            {
              path:'/course-details-page/:id',
              name:"course-details-page",
              meta:{
                title:'课程详情页'
              },
              component:CourseDetailsPage
            },
            {
              path:'/administrator-modifiy',
              name:"administrator-modifiy",
              meta:{
                title:'管理员资料修改'
              },
              component:AdministratorModifiy
            },
            {
              path:'/markSimos-details/:id',
              name:"markSimos-details",
              meta:{
                title:'课程详情页'
              },
              component:MarkSimosDetails
            },
            {
              path:'/toolList',
              name:"toolList",
              meta:{
                title:'攻略百科-理论列表页'
              },
              component:ToolList
            },
            {
              path:'/toolList-details',
              name:"toolList-details",
              meta:{
                title:'攻略百科-理论列表详情页'
              },
              component:ToolListDetails
            },
            {
              path:'/invite-creatCourses',
              name:"invite-creatCourses",
              meta:{
                title:'可邀请创建课程'
              },
              component:InviteCreatCourses
            },
            {
              path:'/invite-coursesDetails',
              name:"invite-coursesDetails",
              meta:{
                title:'可邀请课程详情'
              },
              component:InviteCoursesDetails
            },

            {
              path:'/create-generalcourse',
              name:"create-generalcourse",
              meta:{
                title:'创建普通课程'
              },
              component:CreateGeneralCourse
            },
            {
              path:'/admin-inviteCourse',
              name:"admin-inviteCourse",
              meta:{
                title:'管理员邀请课程'
              },
              component:AdminInviteCourse
            },
            {
              path:'/sign-upCourse',
              name:"sign-upCourse",
              meta:{
                title:'可报名课程'
              },
              component:SignUpCourse
            },
            {
              path:'/myGrades',
              name:"myGrades",
              meta:{
                title:'我的成绩'
              },
              component:MyGrades
            },
            {
              path:'/course-management',
              name:"course-management",
              meta:{
                title:'课程管理'
              },
              component:CourseManagement
            },
            {
              path:'/initiate-invitation',
              name:"initiate-invitation",
              meta:{
                title:'发起邀请'
              },
              component:InitiateInvitation
            },
            {
              path:'/initiate-invitation-page',
              name:"initiate-invitation-page",
              meta:{
                title:'发起邀请详情页'
              },
              component:InitiateInvitationPage
            },
            {
              path:'/curriculum-schedule',
              name:"curriculum-schedule",
              meta:{
                title:'课程列表'
              },
              component:CurriculumSchedule
            },
            {
              path:'/general-coursedetails/:id',
              name:"general-coursedetails",
              meta:{
                title:'创建一般课程详情'
              },
              component:GeneralCoursedetails
            },
            {
              path:'/invite-coursedetails/:id',
              name:"invite-coursedetails",
              meta:{
                title:'创建可邀请课程详情'
              },
              component:InviteCoursedetails
            },
            
            {
              path:'/feedback',
              name:"feedback",
              meta:{
                title:'反馈'
              },
              component:Feedback
            },
            {
              path:'/report',
              name:"report",
              meta:{
                title:'报告'
              },
              component:Report
            },
            {
              path:'/addStudents',
              name:"addStudents",
              meta:{
                title:'添加学员'
              },
              component:AddStudents
            },
            {
              path:'/personal-course-list',
              name:"personal-course-list",
              meta:{
                title:'个人课程列表'
              },
              component:PersonalCourseList
            },
            {
              path:'/new-add-student',
              name:"new-add-student",
              meta:{
                title:'新增学员'
              },
              component:NewAddStudent
            },
            {
              path:'/invite-has-student',
              name:"invite-has-student",
              meta:{
                title:'邀请已有学员'
              },
              component:inviteHasStudent
            },
            {
              path:'/has-invite-participants/:courseId',
              name:"has-invite-participants",
              meta:{
                title:'已接受邀请学员'
              },
              component:hasInviteParticipants
            },
            
	      	]
      },

      // GOD管理员
      {
      	path: '/godLogin',
      	name: 'godLogin',
      	component: GodLogin
      },
      {
      	path: '/godForgetpassword',
      	name: 'godForgetpassword',
      	component: GodForgetpassword
      },
      {
      	path: '/godRestpassword',
      	name: 'godRestpassword',
      	component: GodRestpassword
      },
      {
      	path: '/modify-email',
      	name: 'modify-email',
      	component: ModifyEmail
      },
      {
      	path: '/modify-password',
      	name: 'modify-password',
      	component: ModifyPassword
      },
      {
        path: '/admin-custom-home',
      	name: 'admin-custom-home',
      	component: AdminCustomHome,
        meta:{
          title:'管理员账号'
      },
        
        children:[
          // {
          //   path:'/admin-custom-information',
          //   name:'admin-custom-information',
          //   meta:{
          //     title:'管理员资料修改'
          //   },
          //   component:AdminCustomInformation
          // },
          // {
          //   path:'/admin-custom-setup',
          //   name:'admin-custom-setup',
          //   meta:{
          //     title:'管理员账号设置'
          //   },
          //   component:AdminCustomSetup
          // },
          {
            path: '/home',
	      			name: 'home',
              meta:{
                  title: '首页',
              },
	      			component: Home
          },
          
        ]
      },
      {
        path:'/admin-custom-information',
        name:'admin-custom-information',
        meta:{
          title:'管理员资料修改'
        },
        component:AdminCustomInformation
      },
      {
        path:'/admin-custom-setup',
        name:'admin-custom-setup',
        meta:{
          title:'管理员账号设置'
        },
        component:AdminCustomSetup
      },
      {
        path:'/admin-custom-index',
        name:'admin-custom-index',
        meta:{
          title:'总管理员账号设置'
        },
        component:AdminCustomIndex
      },
      {
        path:'/admin-custom-total',
        name:'admin-custom-total',
        meta:{
          title:'总管理员资料'
        },
        component:AdminCustomTotal
      },
      {
        path:'/admin-custom-all',
        name:'admin-custom-all',
        meta:{
          title:'创建总管理员'
        },
        component:AdminCustomAll
      },
      
      

      
  	]
});

// 登录
router.beforeEach((to, from, next) => {
 // next();
 if(to.name == 'forgetPassword' || to.name == 'businessForgetpassword' || 
    to.name == "godLogin" || to.name == "godForgetpassword" || to.name == "admin-custom-home" || 
    to.name == "business-reset-password" || to.name == 'godRestpassword' || to.name == 'modify-email' ||
    to.name == 'modify-password' || to.name == 'personalRegister'
  ){
   next()
 }else{
    let loginSession=sessionStorage.getItem("login");
    if(loginSession==undefined || JSON.parse(loginSession)==""){
      if(to.name=="Login"){
        next();
      }else{
        Message.error({
          showClose:true,
          message:"请先登录！",
          duration:2000,
          type: 'error',
        });
        next({name:"Login"})
      }
    }else{
      next();
    }
 }
  console.log("router-name:"+to.name)
})

// GOD管理员
router.afterEach((to, from, next) => {
  //next();
  //console.log("router-name:"+to.name)
})

export default router
